home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / DeskBus.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  7.0 KB  |  206 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        DeskBus.p
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1987-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT DeskBus;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __DESKBUS__}
  28. {$SETC __DESKBUS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC DeskBusIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __MACTYPES__}
  35. {$I MacTypes.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40.  
  41.  
  42. {$PUSH}
  43. {$ALIGN MAC68K}
  44. {$LibExport+}
  45.  
  46. {$IFC TARGET_OS_MAC }
  47.  
  48. TYPE
  49.     ADBAddress                            = SInt8;
  50. {$IFC TYPED_FUNCTION_POINTERS}
  51.     ADBCompletionProcPtr = PROCEDURE(buffer: Ptr; refCon: Ptr; command: LONGINT);
  52. {$ELSEC}
  53.     ADBCompletionProcPtr = Register68kProcPtr;
  54. {$ENDC}
  55.  
  56. {$IFC TYPED_FUNCTION_POINTERS}
  57.     ADBDeviceDriverProcPtr = PROCEDURE(devAddress: SInt8; devType: SInt8);
  58. {$ELSEC}
  59.     ADBDeviceDriverProcPtr = Register68kProcPtr;
  60. {$ENDC}
  61.  
  62. {
  63.     TempADBServiceRoutineUPP is needed because of circular definition of
  64.     ADBServiceRoutineProcPtr and ADBServiceRoutineUpp depending on each other.
  65. }
  66.     TempADBServiceRoutineUPP            = ProcPtr;
  67. {$IFC TYPED_FUNCTION_POINTERS}
  68.     ADBServiceRoutineProcPtr = PROCEDURE(buffer: Ptr; completionProc: TempADBServiceRoutineUPP; refCon: Ptr; command: LONGINT);
  69. {$ELSEC}
  70.     ADBServiceRoutineProcPtr = Register68kProcPtr;
  71. {$ENDC}
  72.  
  73.     ADBCompletionUPP = UniversalProcPtr;
  74.     ADBDeviceDriverUPP = UniversalProcPtr;
  75.     ADBServiceRoutineUPP = UniversalProcPtr;
  76. {$IFC TYPED_FUNCTION_POINTERS}
  77.     ADBInitProcPtr = PROCEDURE(callOrder: SInt8);
  78. {$ELSEC}
  79.     ADBInitProcPtr = Register68kProcPtr;
  80. {$ENDC}
  81.  
  82.     ADBInitUPP = UniversalProcPtr;
  83.     ADBDataBlockPtr = ^ADBDataBlock;
  84.     ADBDataBlock = PACKED RECORD
  85.         devType:                SInt8;                                    {  original handler ID  }
  86.         origADBAddr:            SInt8;                                    {  original ADB Address  }
  87.         dbServiceRtPtr:            ADBServiceRoutineUPP;                    {  service routine pointer  }
  88.         dbDataAreaAddr:            Ptr;                                    {  this field is passed as the refCon parameter to the service routine  }
  89.     END;
  90.  
  91.     ADBDBlkPtr                            = ^ADBDataBlock;
  92.     ADBSetInfoBlockPtr = ^ADBSetInfoBlock;
  93.     ADBSetInfoBlock = RECORD
  94.         siService:                ADBServiceRoutineUPP;                    {  service routine pointer  }
  95.         siDataAreaAddr:            Ptr;                                    {  this field is passed as the refCon parameter to the service routine  }
  96.     END;
  97.  
  98.     ADBSInfoPtr                            = ^ADBSetInfoBlock;
  99. { ADBOpBlock is only used when calling ADBOp from 68k assembly code }
  100.     ADBOpBlockPtr = ^ADBOpBlock;
  101.     ADBOpBlock = RECORD
  102.         dataBuffPtr:            Ptr;                                    {  buffer: pointer to variable length data buffer  }
  103.         opServiceRtPtr:            ADBServiceRoutineUPP;                    {  completionProc: completion routine pointer  }
  104.         opDataAreaPtr:            Ptr;                                    {  refCon: this field is passed as the refCon parameter to the completion routine  }
  105.     END;
  106.  
  107.     ADBOpBPtr                            = ^ADBOpBlock;
  108. PROCEDURE ADBReInit;
  109.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  110.     INLINE $A07B;
  111.     {$ENDC}
  112. {
  113.     ADBOp has a different interface for 68k assembly than for everything else
  114.     for 68k assembly the interface is 
  115.     #pragma parameter __D0 ADBOp(__A0,__D0)
  116.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  117. }
  118. {
  119.     IMPORTANT NOTE:
  120.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  121.     four parameters using 68k register based calling conventions, specifically the completion routine
  122.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  123.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  124.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  125.     the mistake cannot be corrected.
  126.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  127.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  128.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  129.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  130. }
  131. FUNCTION ADBOp(refCon: Ptr; compRout: ADBCompletionUPP; buffer: Ptr; commandNum: INTEGER): OSErr;
  132. FUNCTION CountADBs: INTEGER;
  133.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  134.     INLINE $A077, $3E80;
  135.     {$ENDC}
  136. FUNCTION GetIndADB(VAR info: ADBDataBlock; devTableIndex: INTEGER): ADBAddress;
  137.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  138.     INLINE $301F, $205F, $A078, $1E80;
  139.     {$ENDC}
  140. FUNCTION GetADBInfo(VAR info: ADBDataBlock; adbAddr: ADBAddress): OSErr;
  141.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  142.     INLINE $101F, $205F, $A079, $3E80;
  143.     {$ENDC}
  144. FUNCTION SetADBInfo({CONST}VAR info: ADBSetInfoBlock; adbAddr: ADBAddress): OSErr;
  145.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  146.     INLINE $101F, $205F, $A07A, $3E80;
  147.     {$ENDC}
  148.  
  149. CONST
  150.     uppADBCompletionProcInfo = $007B9802;
  151.     uppADBDeviceDriverProcInfo = $00050802;
  152.     uppADBServiceRoutineProcInfo = $0F779802;
  153.     uppADBInitProcInfo = $00000802;
  154.  
  155. FUNCTION NewADBCompletionProc(userRoutine: ADBCompletionProcPtr): ADBCompletionUPP;
  156.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  157.     INLINE $2E9F;
  158.     {$ENDC}
  159.  
  160. FUNCTION NewADBDeviceDriverProc(userRoutine: ADBDeviceDriverProcPtr): ADBDeviceDriverUPP;
  161.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  162.     INLINE $2E9F;
  163.     {$ENDC}
  164.  
  165. FUNCTION NewADBServiceRoutineProc(userRoutine: ADBServiceRoutineProcPtr): ADBServiceRoutineUPP;
  166.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  167.     INLINE $2E9F;
  168.     {$ENDC}
  169.  
  170. FUNCTION NewADBInitProc(userRoutine: ADBInitProcPtr): ADBInitUPP;
  171.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  172.     INLINE $2E9F;
  173.     {$ENDC}
  174.  
  175. PROCEDURE CallADBCompletionProc(buffer: Ptr; refCon: Ptr; command: LONGINT; userRoutine: ADBCompletionUPP);
  176.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  177.     {To be implemented:  Glue to move parameters into registers.}
  178.     {$ENDC}
  179.  
  180. PROCEDURE CallADBDeviceDriverProc(devAddress: SInt8; devType: SInt8; userRoutine: ADBDeviceDriverUPP);
  181.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  182.     {To be implemented:  Glue to move parameters into registers.}
  183.     {$ENDC}
  184.  
  185. PROCEDURE CallADBServiceRoutineProc(buffer: Ptr; completionProc: TempADBServiceRoutineUPP; refCon: Ptr; command: LONGINT; userRoutine: ADBServiceRoutineUPP);
  186.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  187.     {To be implemented:  Glue to move parameters into registers.}
  188.     {$ENDC}
  189.  
  190. PROCEDURE CallADBInitProc(callOrder: SInt8; userRoutine: ADBInitUPP);
  191.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  192.     {To be implemented:  Glue to move parameters into registers.}
  193.     {$ENDC}
  194. {$ENDC}  {TARGET_OS_MAC}
  195.  
  196. {$ALIGN RESET}
  197. {$POP}
  198.  
  199. {$SETC UsingIncludes := DeskBusIncludes}
  200.  
  201. {$ENDC} {__DESKBUS__}
  202.  
  203. {$IFC NOT UsingIncludes}
  204.  END.
  205. {$ENDC}
  206.